import uniqueId from '@form-create/utils/lib/unique';
import {localeProps, makeRequiredRule} from '../../utils';

const label = '时间区间';
const name = 'timeRange';

export default {
  icon: 'icon-time',
  label,
  name,
  rule({t}) {
    return {
      type: 'a-time-picker',
      field: uniqueId(),
      title: t('components.timeRange.name'),
      info: '',
      $required: false,
      props: {
        type: 'time-range',
      },
    };
  },
  props(_, {t}) {
    return localeProps(t, 'timePicker.props', [
      makeRequiredRule(),
      {
        type: 'input',
        field: 'placeholder',
        title: '非范围选择时的占位内容'
      },
      {
        type: 'input',
        field: 'format',
        title: '展示日期的格式'
      },
      {
        type: 'switch',
        field: 'readonly'
      },
      {
        type: 'switch',
        field: 'disabled'
      },
      {
        type: 'switch',
        title: '是否允许清除',
        field: 'allowClear',
        value: true
      },
      {
        type: 'Struct',
        field: 'pickerOptions',
        props: {
          defaultValue: {}
        }
      },
      {
        type: 'switch',
        field: 'editable',
        value: true
      }
    ]);
  }
};
